﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Zusammenfassungsbeschreibung für IP
/// </summary>
public class IP
{
	public IP()
	{
		// Unkonwn IP addresses
		// 62.249.170.129
		// 
	}
	public enum FriendOrFoe { Uninitialized = 0, Friend = 1, Foe = 2, Unknown = 3 };
	private static string _remoteIp = null;
	public static string RemoteIp
	{
		get
		{
			if (_remoteIp == null)
				_remoteIp = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
			return _remoteIp;
		}
	}
	private static FriendOrFoe _friendOrFoeStatus = FriendOrFoe.Uninitialized;
	public static FriendOrFoe FriendOrFoeStatus
	{
		get
		{
			if (_friendOrFoeStatus == FriendOrFoe.Uninitialized)
				_friendOrFoeStatus = IsFriendOrFoe(RemoteIp);
			return _friendOrFoeStatus;
		}
	}
	private static FriendOrFoe IsFriendOrFoe(string ipAddress)
	{
		FriendOrFoe returns = FriendOrFoe.Unknown;
		if (ipAddress.StartsWith("194.208.39") || ipAddress.StartsWith("84.253.46") || ipAddress.StartsWith("88.84.23") || ipAddress.StartsWith("217.193.156.22"))
			return FriendOrFoe.Foe;
		if ((ipAddress=="188.21.193.194")||(ipAddress=="127.0.0.1")||ipAddress.StartsWith("66.249.68")
			|| ipAddress.StartsWith("91.115.32")||ipAddress.StartsWith("62.47.239"))
			return FriendOrFoe.Friend;
		return returns;
	}
}
